import { PureComponent, createRef } from "react"
import VirtualClassDOM from "./components/普通虚拟dom节点的获取"

export default class Page1 extends PureComponent {
  constructor() {
    super()
    this.VirtualClassDOM = createRef() // 官方推荐这种获取
  }
  getVirtualClassDOMRef() {
    // 注意这里不能获取组件的方法（例如子组件的getRef方法)，只能获取实例属性，为什么要这么屏蔽拿方法的设计？
    console.log(
      this.VirtualClassDOM.current,
      this.VirtualClassDOM.current.refDOM1.current
    )
  }
  render() {
    return (
      <>
        <h2>Page1</h2>
          <button onClick={() => this.getVirtualClassDOMRef()}>
              获取子组件(类组件)
          </button>
        <VirtualClassDOM ref={this.VirtualClassDOM} />
      </>
    )
  }
}
